{layout name="../common/master"/}
<div id="right">
       <h4 style="border-bottom: 1px solid #ccc;padding-bottom: 3px">所有产品列表   <a type="button" href="{:URL('home/Product/productAdd')}" class="btn btn-success">添加</a></h4>
    <!--<form action="" method="post" role="form">-->
        <!--<div class="form-group">-->
            <!--<input type="text" style="width: 200px;float: left;margin-right: 20px" class="form-control" value="{if condition='isset($uname)'}{$uname}{/if}" name="uname" id="" placeholder="上传名">-->
        <!--</div>-->
        <!--<button type="submit" class="btn btn-primary">查询</button>-->
        <!--<a href="{:URL('home/Docmanager/docupload')}" class="btn btn-success">上传文件</a>-->
    <!--</form>-->
    <table class="table-bordered table  table-hover" style="margin-top: 20px;">
        <thead>
        <tr>
            <th>序号</th>
            <th>产品名称</th>
            <th>价格</th>
            <th>时长</th>
            <th>年利率</th>
            <th>信审费</th>
            <th>管理费</th>
            <th>逾期费率</th>
            <th>是否上架</th>
            <th>操作</th>
        </tr>
        </thead>
        <tbody>
        {foreach name="data" item="vo" key="k"}
            <tr>
                <th>{$k+1}</th>
                <th>{$vo['name']}</th>
                <th>{$vo['price']}</th>
                <th>{$vo['period']}</th>
                <th>{$vo['product_rate']}</th>
                <th>{$vo['info_check_fee']}</th>
                <th>{$vo['manage_fee']}</th>
                <th>{$vo['overdue_rate']}</th>
                {if condition="$vo['is_valid'] eq 0" }
                <th>未上架</th>
                {elseif condition="$vo['is_valid'] eq 1"/}
                <th>已上架</th>
                {/if}
                <th>
                    <div class="btn-group">
                        {if condition="$vo['is_valid'] eq 0" }
                        <button uid="{$vo['id']}" class="toStore btn btn-success btn-sm">上架</button>
                        {elseif condition="$vo['is_valid'] eq 1"/}
                        <button uid="{$vo['id']}" class="downStore btn btn-danger btn-sm">下架</button>
                        {/if}
                        <a style="margin-left: 5px" href="{:URL('home/Product/productList?type=info',['uid'=>$vo['id']])}" class="btn btn-primary btn-sm">查看详情</a>
                    </div>
                </th>
            </tr>
        {/foreach}
        </tbody>
    </table>
    {$page} 总产品数：{$totalCount}

</div>
<script>
    $(".toStore").click(function(){
        var data={
            is_valid:1
        }
        var id=$(this).attr('uid');
        var url="{:URL('home/Product/upStore')}"+"?id="+id;
        $.post(url,data,function(res){
            if(res.code == 0){
                location.reload();
            }else{
                layer.msg(res.data,function(){});
            }
        })
    })
    $(".downStore").click(function(){
        var data={
            is_valid:0
        }
        var id=$(this).attr('uid');
        var url="{:URL('home/Product/upStore')}"+"?id="+id;
        $.post(url,data,function(res){
            if(res.code == 0){
                location.reload();
            }else{
                layer.msg(res.data,function(){});
            }
        })
    })
</script>
